<%--
    Document   : process
    Created on : Apr 7, 2011, 10:25:35 AM
    Author     : Muhammad Anis
--%>
<%@page import="java.util.List"%>
<%@page import="system.chatbetweenfriend"%>
<%@page import="tools.commandProcessor"%>
<%@page import="user.user"%>
<%@page import="tools.dbconnector"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="tools.writer" %>
<jsp:useBean id="chatbeetwenfriend" class="system.chatbetweenfriend" scope="application" />
<jsp:useBean id="allover" class="system.allover" scope="application" />
<%

            String task = request.getParameter("task");
            if (task != null) {
                dbconnector db = new dbconnector(out);
                user currentuser = (user) session.getAttribute("currentuser");
                if(task.equals("updateTab")){
                    //task=updateTab&&tipe=friend&&status=passive&&friend="+username
                    String tipe = request.getParameter("tipe");
                    String status = request.getParameter("status");
                    String friend = request.getParameter("friend");
                    if(tipe.equals("friend")){
                        if(status.equals("active")){
                            chatbeetwenfriend.printChat(currentuser.username, friend, out);
                        }
                        else{
                            try{
                            if(chatbeetwenfriend.isUpdate(currentuser.username, friend))
                                out.print("@update@");
                            else
                                 out.print("@tidak@");
                            }catch(Exception e){
                                System.out.println(e.getMessage());
                            }
                        }
                    } else if(tipe.equals("room")){
                        if(status.equals("active")){
                            allover.printChat(friend, out);
                        } else{
                            if(allover.isRoomUpdated(friend))
                                 out.print("@update@");
                            else
                                 out.print("@tidak@");
                            
                        }
                    }
                }

            } else {
                writer.redirect("../index.jsp", out);
            }
%>